const groupA = [
    {
        passengerId: "PAX-1",
        bagTagData: ["tag A", "tag B"]
    },
    {
        passengerId: "PAX-2",
        bagTagData: ["tag 1", "tag 2"]
    }
]

const groupB = [
    {
        passengerId: "PAX-1",
        bagTagData: ["tag C", "tag D"]
    },
    {
        passengerId: "PAX-2",
        bagTagData: ["tag 3", "tag 4"]
    },
    {
        passengerId: "PAX-3",
        bagTagData: ["tag 5", "tag 6"]
    }
]

const latestBagTags = [...groupA, ...groupB].reduce(
    (acc, cur) => {
        const isValidData = acc.find(item => item.passengerId === cur.passengerId);
        if (isValidData) {
            isValidData.bagTagData = [...new Set([...isValidData.bagTagData, ...cur.bagTagData])];
        } else {
            acc.push({ ...cur });
        }
        return acc;
    }, []);


console.info(latestBagTags)

/**
 * 
    [
        {passengerId: 'PAX-1',bagTagData: [ 'tag A', 'tag B', 'tag C', 'tag D' ]},
        {passengerId: 'PAX-2',bagTagData: [ 'tag 1', 'tag 2', 'tag 3', 'tag 4' ]},
        { passengerId: 'PAX-3', bagTagData: [ 'tag 5', 'tag 6' ] }
    ]
 */